#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
using namespace std;
struct Node
{
	long long d,v,a;
	bool flag;
	vector<long long> o;
}car[100005];
bool w[1000005];
long long dis[100005],tw[100005];
long long findx(const vector<long long> v,long long x)
{
	long long len=v.size();
	for(long long i=0;i<len;i++)
	{
		if(v[i]==x)
		{
			return true;
		}
	}
	return false;
}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	cin>>T;
	while(T--)
	{
		long long n,m,l,v;
		scanf("%lld%lld%lld%lld",&n,&m,&l,&v);
		for(long long i=1;i<=n;i++)
		{
			scanf("%lld%lld%lld",&car[i].d,&car[i].v,&car[i].a);
			car[i].flag=0;
			car[i].o.clear();
		}
		for(long long i=0;i<=l;i++)
		{
			w[i]=false;
		}
		for(long long i=1;i<=m;i++)
		{
			scanf("%lld",dis+i);
			w[dis[i]]=1;
		}
		for(long long i=1;i<=n;i++)
		{
			long long j=car[i].d;
			while(j<=l)
			{
				if(w[j])
				{
					long double vv=sqrt((long double)(car[i].v*car[i].v)+(long double)(2*car[i].a*(j-car[i].d)));
					long long t=vv;
					if(t>v)
					{
						car[i].flag=1;
						car[i].o.push_back(j);
					}else if((long double)(t)!=vv&&t==v)
					{
						car[i].flag=1;
						car[i].o.push_back(j);
					}
				}
				j++;
			}
		}
		long long ans=0;
		for(long long i=1;i<=n;i++)
		{
			if(car[i].flag)
			{
				ans++;
			}
		}
		printf("%lld ",ans);
		bool sign=true;
		ans=0;
		memset(tw,0,sizeof(tw));
		while(sign)
		{
			sign=false;
			for(long long i=1;i<=m;i++)
			{
				if(tw[i]) continue;
				bool t=true;
				for(long long j=1;j<=n;j++)
				{
					if(findx(car[j].o,dis[i])&&car[j].o.size()<=1)
					{
						t=false;
						break;
					}
				}
				if(t)
				{
					ans++;
					sign=true;
					tw[i]=1;
					for(long long j=1;j<=n;j++)
					{
						if(findx(car[j].o,dis[i]))
						{
							queue<long long> q;
							while(car[j].o.back()!=dis[i])
							{
								q.push(car[j].o.back());
								car[j].o.pop_back();
							}
							car[j].o.pop_back();
							while(!q.empty())
							{
								car[j].o.push_back(q.front());
								q.pop();
							}
						}
					}
				}
				//if(i==5) return 0;
			}
			
		}
		printf("%lld\n",ans);
	}
	return 0;
}
